package com.cloud.service;

import com.cloud.constant.RedisKeyConstants;
import com.cloud.pojo.movie.ImportMovie;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @version v1.0
 * @author: TianXiang
 * @description: 导入视频策略接口
 * @date: 2020/11/24
 */
public interface ImportMovieService {

    void importMovie(ImportMovie importMovie, MultipartFile movieFile, RabbitTemplate rabbitTemplate, RedisTemplate<String,String> redisTemplate);

    /**
     * 视频名称不带后缀
     */
    default boolean cacheExistMoive(String movieName, RedisTemplate<String,String> redisTemplate) {
        List<String> list = redisTemplate.opsForList().range(RedisKeyConstants.MOVIE_LIST_KEY, 0, -1);
        return list.stream().anyMatch(item -> item.equals(movieName));
    }

}
